home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / res / explorer / Photo1 / index.php < prev    next >
PHP Script  |  2010-05-19  |  12KB  |  332 lines

  1. <?php
  2. /**
  3.  * Photo album V4
  4.  *
  5.  * Display a photo album based on files located in a given directory (and subdirs)
  6.  * Display thumbnails and preview.
  7.  * Display full size view in separate window
  8.  *
  9.  * PHP version 5
  10.  *
  11.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  12.  * that is available through the world-wide-web at the following URI:
  13.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  14.  * the PHP License and are unable to obtain it through the web, please
  15.  * send a note to license@php.net so we can mail you a copy immediately.
  16.  *
  17.  * @category   NA
  18.  * @package    NA
  19.  * @author     Nicolas Bruley / Peer 2 World <contact@weezo.net>
  20.  * @copyright  2005-2009 Nicolas Bruley / Peer 2 World
  21.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  22.  * @version    CVS: $Id:$
  23.  * @link       http://www.weezo.net
  24.  * @since      File available since Release 1.0.0
  25.  */
  26.  
  27. require(INCLUDE_DIR.'explorerFunctions.php');
  28. require(INCLUDE_DIR.'outputFunctions.php');
  29.  
  30. $_ENV['COMBINED_LAYOUTS']=array('20'=>2,'21'=>2,'10'=>1,'30'=>3,'31'=>3,'32'=>3,'40'=>4);
  31.  
  32. /**
  33.  * @desc Init / update (from setCombinedLayout async POST) combinedLayout propertie
  34.  */
  35. function initCombinedLayout(){
  36.     // Backward compatibility: set combinedLayout for Photo1 resources
  37.     if(!cfRGetVar('combinedLayout')) {
  38.         cfRSetVar('combinedLayout','10');
  39.         // and force 240px thumbnails as Photo1 thumbnails were too small for other displays
  40.         cfRSetVar('thumbnailsSize',240);
  41.     }
  42.  
  43.     $prev=cfRGetVar('combinedLayout');
  44.     $new=@$_POST['setCombinedLayout'];
  45.     if(!isset($_ENV['COMBINED_LAYOUTS'][$new])) $new=$prev;
  46.  
  47.     // combinedLayout updated
  48.     if($prev!==$new || !cfRGetVar('combinedLayoutInitialized')){
  49.         // Set combinedLayout
  50.         cfRSetVar('combinedLayout',$new);
  51.         $mainLayout= $new[0];
  52.         $subLayout = $new[1];
  53.  
  54.  
  55.         switch ($_ENV['COMBINED_LAYOUTS'][$new]){
  56.             case 1:
  57.                 // Display preview image
  58.                 cfRSetVar('previewDisplay',true);
  59.  
  60.                 // Reset thumbnails cropping and specific tooltip image size (Photo1 & Photo2)
  61.                 cfRUnsetVar('cropThumbnails');
  62.                 cfRUnsetVar('tooltipImageWidth');
  63.                 cfRUnsetVar('tooltipImageHeight');
  64.  
  65.                 // Use filesLayoutResource() javascript function to async update files
  66.                 cfRSetVar('filesLayout','customIcons');
  67.  
  68.                 // Thumbnails interval
  69.                 cfRSetVar('resourceLayout','useInterval');
  70.                 cfRSetVar('itemsPerPage',cfRGetVar('itemsPerPageLayout1'));
  71.                 break;
  72.             case 2:
  73.                 // Don't display preview image
  74.                 cfRSetVar('previewDisplay',false);
  75.                 if($new=='20')    cfRSetVar('filesLayout','list'); else cfRSetVar('filesLayout','icons');
  76.  
  77.                 // Thumbnails
  78.                 cfRUnsetVar('cropThumbnails');
  79.                 cfRUnsetVar('tooltipImageWidth');
  80.                 cfRUnsetVar('tooltipImageHeight');
  81.  
  82.                 // Thumbnails interval
  83.                 if($new=='20'){
  84.                     // List display: show all
  85.                     cfRSetVar('resourceLayout','all');
  86.                 }
  87.                 else{
  88.                     // Icons display: show only interval
  89.                     cfRSetVar('resourceLayout','useInterval');
  90.                     cfRSetVar('itemsPerPage',cfRGetVar('itemsPerPageLayout2'));
  91.                 }
  92.                 break;
  93.             case 3:
  94.                 // Crop thumbnails, enlarge 150% before cropping, set specific tooltip image size
  95.                 cfRSetVar('cropThumbnails',150);
  96.                 cfRInitVar('tooltipImageWidth',400);
  97.                 cfRInitVar('tooltipImageHeight',300);
  98.  
  99.                 // Set layout from subLayout (inverted values)
  100.                 cfRSetVar('layout',2-$subLayout);
  101.  
  102.                 // Display or not the preview image (Photo3)
  103.                 if(cfRGetVar('layout')>0) cfRSetVar('previewDisplay',true); else cfRSetVar('previewDisplay',false);
  104.  
  105.                 // Use filesLayoutResource() javascript function to async update files
  106.                 cfRSetVar('filesLayout','customIcons');
  107.  
  108.                 // Display all Thumbnails
  109.                 cfRSetVar('resourceLayout','all');
  110.                 break;
  111.             case 4:
  112.                 // Don't display preview image
  113.                 cfRSetVar('previewDisplay',false);
  114.  
  115.                 // Use filesLayoutResource() javascript function to async update files
  116.                 cfRSetVar('filesLayout','customIcons');
  117.  
  118.                 // Thumbnails
  119.                 cfRUnsetVar('cropThumbnails');
  120.                 cfRUnsetVar('tooltipImageWidth');
  121.                 cfRUnsetVar('tooltipImageHeight');
  122.  
  123.                 // Icons display: show only interval
  124.                 cfRSetVar('resourceLayout','useInterval');
  125.                 cfRInitVar('itemsPerPageLayout4',50);
  126.                 cfRSetVar('itemsPerPage',cfRGetVar('itemsPerPageLayout4'));
  127.                 break;
  128.         }
  129.         cfRSetVar('combinedLayoutInitialized',1);
  130.  
  131.         // If user requested a new layout, sync reload page, except if Photo2->Photo2 or Photo3->Photo3
  132.         if(isset($_POST['setCombinedLayout'])){
  133.             if($_ENV['COMBINED_LAYOUTS'][$new]!==$_ENV['COMBINED_LAYOUTS'][$prev]) {
  134.                 cfAsyncHeader();
  135.                 echo cfAsyncXMLJSaction('wl.goURL()');
  136.                 die(cfAsyncFooter());
  137.             }
  138.         }
  139.     }
  140. }
  141.  
  142. /**
  143.  * @desc init photo explorer
  144.  *
  145.  */
  146. function initPhotoExplorerData(){
  147.     if(!cfRGetVar('resourceParametersInitialized')){
  148.         cfRSetVar('extensionFilter',false); // No filter on extension
  149.         cfRSetVar('fileTypeFilter',array('image')); // Only display images
  150.         cfRSetVar('efEditMode',false);// Startup comments edit mode (false:view, true:edit)
  151.         cfRInitVar('thumbnailsIndex','0'); // index of first displayed thumbnail
  152.         cfRInitVar('activePreview',0); // index of preview image
  153.         cfRSetVar('displayMultipleDownload',true); // Display multiple download box (only if multipleDownloadAllowed)
  154.         cfRInitVar('actionsPanel',1); // Right panel unfolded
  155.         cfRInitVar('CLSShow',1); // Show combined layout selector
  156.  
  157.         // Backward compatibility: new functions use thumbnailsSize instead of efThumbnailsMaxWidth
  158.         cfRInitVar('thumbnailsSize',240); // Size of generated thumbnails, and of full-size thumbnails
  159.         cfRInitVar('thumbnailsSizeFactor',2); // thumbnailsSize modifier of thumbnails: 0=>1/4, 1=>1/2, 2=>1/1
  160.  
  161.         // Browser specific parameters
  162.         if(!cfBGetVar('download'))    {
  163.             cfRSetVar('multipleDownloadAllowed',false);
  164.             cfRSetVar('downloadShortcut',false);
  165.             cfRSetVar('uploadAllowed',false);
  166.         }
  167.  
  168.         // indicate that parameters have been initialized
  169.         if(cfRGetVar('resourceConfigured')) cfRSetVar('resourceParametersInitialized',true);
  170.         else $errorMessageCritical=cfCaption('configErrorNotConfigured');
  171.     }
  172.  
  173.     // Init treeview
  174.     global $tree;
  175.     if(cfRGetVar('treeViewAvailable')){
  176.         cfRSetVar('treeViewDisplayed',true);
  177.         $tree=new treeViewFolder(cfRGetVar('treeViewAvailable'));
  178.         $tree=treeFolderLoad(cfRGetVar('treeViewAvailable'));
  179.         $tree->syncSelectPath=false;
  180.     }
  181.     else cfRSetVar('treeViewDisplayed',false);
  182. }
  183.  
  184. /**
  185.  * @desc Insert HTML code for combinedLayout selector
  186.  *
  187.  */
  188. function photoCombinedLayoutSelector(){
  189.     // Set layouts icons
  190.     $current=cfRGetVar('combinedLayout');
  191.     foreach ($_ENV['COMBINED_LAYOUTS'] as $key=>$value) {
  192.         $icon=outIcon('photoLayout'.$key);
  193.         echo outBlockItem('combinedLayoutSwitch','<img src="'.$icon.'" alt="" style="width:48px;height:48px">','id="combinedLayoutSwitch'.$key.'"','margin-right:7px;margin-left:0px;padding:8px;',array('onclick'=>'setCombinedLayout(\''.$key.'\')'),(($key==$current)?'sel':'unsel'));
  194.     }
  195.  
  196.     echo '<i style="margin-right:4em"> </i>';
  197.  
  198.     // Set size selection icons
  199.     $current=cfRGetVar('thumbnailsSizeFactor');
  200.     foreach (array('0'=>'efTNSize480','1'=>'efTNSize481','2'=>'efTNSize482')  as $key=>$value) {
  201.         $icon=outIcon($value);
  202.         echo outBlockItem('sizeFactorSwitch','<img src="'.$icon.'" alt="">',false,'margin-right:7px;margin-left:0px;padding:8px;',array('onclick'=>'sendData(\'data3=efTNSize&data4='.$key.'\')'),(($key==$current)?'sel':'unsel'));
  203.     }
  204.  
  205. }
  206.  
  207. /**
  208.  * @desc Insert frame1 DIV preview title and combinedLayout selector
  209.  *
  210.  */
  211. function photoHeader(){
  212.     global $preview;
  213.  
  214.     echo outDivFrame('frame1');
  215.     $l=$preview->title();
  216.     $r='';
  217.     if(!cfRGetVar('filesLayoutLocked')) $r='<span style="cursor:pointer">'.outImageIcon('combinedLayout').cfCaption('genDisplay').outImage(outIcon(((cfRGetVar('CLSShow'))?'up':'down')),false,'id="CLSToggleIcon"','margin-left:0.5em;vertical-align:middle').'</span>';
  218.     echo outFrameHeaderTable('frame1Header',$l,$r,((cfRGetVar('filesLayoutLocked'))?'':'onclick="CLSToggle()"'));
  219.     echo outDivFrame('banner','id="combinedLayoutSelectorDiv"','overflow:hidden;'.((cfRGetVar('CLSShow'))?'':'height:1px;display:none'));
  220.     if(!cfRGetVar('filesLayoutLocked')) photoCombinedLayoutSelector();
  221.     echo '</div>';
  222. }
  223.  
  224.  
  225.  
  226. // Init common explorer data
  227. efInit();
  228. $preview=new efPreview();
  229.  
  230. // Set/change active combined layout
  231. initCombinedLayout();
  232.  
  233. // Init photo explorer data
  234. initPhotoExplorerData();
  235.  
  236. /**
  237.  * If mobile device, redirect to mobile explorer
  238.  */
  239. if(cfIsMobile()) {require(INCLUDE_DIR.'mobileExplorerFunctions.php');mefExplorer();exit;}
  240.  
  241.  
  242. // Reset preview image rotation
  243. cfRUnsetVar('previewAngle');
  244.  
  245. /*
  246.  ***************************************************************************************************************************
  247.  * Process POST commands
  248.  ***************************************************************************************************************************
  249.  */
  250. efProcessPOST();
  251. cfAsyncXMLChangePhpVarValue('displayMultipleDownload'); // process hide / show multiple download frame dynamic update
  252. cfAsyncXMLChangePhpVarValue(SLIDESHOW_TIMER_CONTROL_NAME,array(1,2,3,4,5,10,15,30)); // process slideshow timeout value change
  253. cfAsyncXMLChangePhpVarValue('actionsPanel'); // process hide / show right panel
  254. cfAsyncXMLChangePhpVarValue('CLSShow',array(0,1)); // process hide / show combinedLayout Selector
  255. if        (cfRGetVar('combinedLayout')=='10') cfRSetVar('itemsPerPageLayout1',cfRGetVar('itemsPerPage')); // Update layout 1 items per page
  256. elseif    (cfRGetVar('combinedLayout')=='21') cfRSetVar('itemsPerPageLayout2',cfRGetVar('itemsPerPage')); // Update layout 2 items per page
  257. elseif    (cfRGetVar('combinedLayout')=='40') cfRSetVar('itemsPerPageLayout4',cfRGetVar('itemsPerPage')); // Update layout 4 items per page
  258.  
  259. /*
  260.  ***************************************************************************************************************************
  261.  * Get files and subfolders list, generate thumbnails if needed
  262.  ***************************************************************************************************************************
  263.  */
  264. efDirUpdate();
  265.  
  266. // If using list view or icon view and async directory selection through treeView, update files view and exit
  267. efFilesListAsyncUpdate();
  268.  
  269. /*
  270.  ***************************************************************************************************************************
  271.  * Insert HEAD, JS functions and form
  272.  ***************************************************************************************************************************
  273.  */
  274. efInsertExplorerHeadAndBody();
  275. ?>
  276. <script type="text/javascript">
  277. var combinedLayout="<?php echo cfRGetVar('combinedLayout');?>";
  278. var subLayout=<?php echo substr(cfRGetVar('combinedLayout'),-1); ?>;
  279. var tnWidth=<?php echo efThumbnailsMaxWidth() ?>;
  280. function CLSToggling(anim){
  281.     setAlpha(anim.item,anim.step)
  282.     winResized();
  283.     dd.recalc();
  284. }
  285. function CLSToggle(){
  286.     if(dgi('combinedLayoutSelectorDiv').style.display=='none'){
  287.         wl.nodeCollapseToggle('combinedLayoutSelectorDiv','CLSShow',CLSToggling)
  288.         /*
  289.         wl.fadeStyle('combinedLayoutSelectorDiv','height',72,'exponential',5,'CLSToggled()');
  290.         sendData('CLSShow=1');
  291.         fade('combinedLayoutSelectorDiv',0,1,10);
  292.         */
  293.         dgi('CLSToggleIcon').src="<?php echo outIcon('up');?>"
  294.     }
  295.     else{
  296.         wl.nodeCollapseToggle('combinedLayoutSelectorDiv','CLSShow',CLSToggling)
  297.         /*
  298.         wl.fadeStyle('combinedLayoutSelectorDiv','height',0,'exponential',5,'CLSToggled()');
  299.         fade('combinedLayoutSelectorDiv',1,0,10);
  300.         sendData('CLSShow=0');
  301.         */
  302.         dgi('CLSToggleIcon').src="<?php echo outIcon('down');?>"
  303.     }
  304. }
  305. // Request a combined layout change
  306. function setCombinedLayout(nl){
  307.     var noTNUpdate;
  308.     if(nl==combinedLayout) return;
  309.     if(nl.substr(0,1)==combinedLayout.substr(0,1) && W.layoutSubLayoutChanged) {
  310.         if(layoutSubLayoutChanged(nl)) noTNUpdate=1;
  311.     }
  312.     combinedLayout=nl;
  313.     sendData('setCombinedLayout='+nl+((noTNUpdate)?'&filesListNoUpdate=1':''));
  314. }
  315.  
  316.  
  317.  
  318. <?php
  319. // Hidden fields
  320. echo $preview->JSDefinition();
  321.  
  322. // Keyboard shortcuts
  323. echo $preview->setKeyboardShortcuts();
  324.  
  325. ?>
  326. </script>
  327.  
  328. <?php
  329.  
  330. // Display page
  331. require(cfAppDocRoot().'/res/explorer/Photo1/layout'.$_ENV['COMBINED_LAYOUTS'][cfRGetVar('combinedLayout')].'.php');
  332. ?>